package deviceinfo.wsm.com.deviceinfo;

import android.Manifest;
import android.util.Log;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * Created by 王家宝 on 2018/7/5.
 * TEL:18241150668
 * MAIL:639586819@qq.com
 */

class DeviceInfoUtil {

    private static final String TAG = "DEVICE_TAG";

    /**
     * 获取定位信息
     */
    static LinkedHashMap<String, String> getLocationInfo() {
        Log.i(TAG, "位置信息" + WsmDeviceInfoSDK.getLocationInfo());
        return WsmDeviceInfoSDK.getLocationInfo();
    }

    /**
     * 获取App信息
     */
    static LinkedHashMap<String, String> getAppInfo() {
        Log.i(TAG, "应用信息" + WsmDeviceInfoSDK.getAppInfo());
        return WsmDeviceInfoSDK.getAppInfo();
    }


    /**
     * 获取设备信息
     *
     * @return
     */
    static LinkedHashMap<String, String> getDeviceInfo() {
        Log.i(TAG, "设备信息" + WsmDeviceInfoSDK.getDeviceInfo());
        return WsmDeviceInfoSDK.getDeviceInfo();
    }


    /**
     * 获取内存信息
     *
     * @return
     */
    static LinkedHashMap<String, String> getMemoryInfo() {
        Log.i(TAG, "内存信息" + WsmDeviceInfoSDK.getRomInfo());
        return WsmDeviceInfoSDK.getRomInfo();
    }


    /**
     * 获取网络信息
     * <p>
     * 需要{@link Manifest.permission.READ_PHONE_STATE}
     *
     * @return
     */
    static LinkedHashMap<String, String> getNetInfo() {
        Log.i(TAG, "网络信息" + WsmDeviceInfoSDK.getNetInfo());
        return WsmDeviceInfoSDK.getNetInfo();
    }

    /**
     * 获取已安装应用信息
     *
     * @return
     */
    static LinkedHashMap<String, String> getInstallPackageInfo() {
        Log.i(TAG, "已安装应用信息" + WsmDeviceInfoSDK.getInstallPackageInfo());
        return WsmDeviceInfoSDK.getInstallPackageInfo();
    }


    /**
     * 获取联系人信息
     * <p>
     * 需要{@link Manifest.permission.READ_CONTACTS}
     *
     * @return
     */
    static LinkedHashMap<String, List> getContactsInfo() {
        Log.i(TAG, "联系人信息" + WsmDeviceInfoSDK.getContactsInfo());
        return WsmDeviceInfoSDK.getContactsInfo();
    }


    /**
     * 获取CPU信息
     *
     * @return
     */
    static LinkedHashMap<String, String> getCPUInfo() {
        Log.i(TAG, "CPU信息" + WsmDeviceInfoSDK.getCpuInfo());
        return WsmDeviceInfoSDK.getCpuInfo();
    }


    /**
     * 获取传感器信息
     */
    static void getSensorInfo() {
        WsmDeviceInfoSDK.startHardwareMonitor(new WsmDeviceInfoSDK.OnHardwareDataBackListener() {
            @Override
            public void onSuccess(ArrayList<LinkedHashMap> sensorResult,
                                  ArrayList<LinkedHashMap> gravitySensorResult,
                                  ArrayList<LinkedHashMap> gyroscopeSensorResult) {
                WsmDeviceInfoSDK.sensorInfo = new LinkedHashMap<>();
                WsmDeviceInfoSDK.sensorInfo.put("加速度计", sensorResult);
                WsmDeviceInfoSDK.sensorInfo.put("重力计", gravitySensorResult);
                WsmDeviceInfoSDK.sensorInfo.put("陀螺仪", gyroscopeSensorResult);

                Log.i(TAG, "加速度计:" + sensorResult);
                Log.i(TAG, "重力计:" + gravitySensorResult);
                Log.i(TAG, "陀螺仪:" + gyroscopeSensorResult);
            }

            @Override
            public void onFailed() {
                WsmDeviceInfoSDK.sensorInfo = new LinkedHashMap<>();
            }
        });
    }


}
